/// @tags:
#include <cstdio>
#include <iostream>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

int main() {
  int n, m;
  cin >> n >> m;
  long long max = 0, min = 0x7fffffffffffffff;
  for (int i = 1; i <= n; ++i) {
    long long a;
    cin >> a;
    max = std::max(max, a);
    min = std::min(min, a);
  }
  while (m--) {
    max = std::max(max * 2, max + 2);
  }
  cout << max - min;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("T1.in", "r", stdin);
  freopen("T1.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
